﻿module Sustainalytics.Portfolio {
    import Common = Sustainalytics.Common;
    import SearchBox = Sustainalytics.SearchBox;

    // Portfolio List controller
    export class PortfolioCheckController {

        public resultCheck: boolean;
        // Ctor.
        constructor(
            private $rootScope: ng.IScope,
            private $scope: ng.IScope,
            private $q: ng.IQService,
            private $location: ng.ILocationService,
            private PortfolioService: PortfolioService,
            private notificationFactory: Common.INotificationFactory,
            private $modal: Common.IModal,
            private $modalInstance: Common.IModalInstance) {

            var ctx = this;
            $scope['portfolioCheck'] = ctx;
        }

        public closeDialog = function () {
            var ctx = this;
            ctx.resultCheck = false;
            ctx.$modalInstance.close({portfolioCheck: ctx.resultCheck});
        };

        public updatePortfolio() {
            var ctx = this;
            var def = this.$q.defer();
            ctx.resultCheck = true;
            this.$modalInstance.close({portfolioCheck: ctx.resultCheck});
        }
    }

    // register controller with News Angular module
    angular.module('Sustainalytics.Portfolio').controller('PortfolioCheckController', function ($rootScope: ng.IScope, $scope: ng.IScope, $q: ng.IQService, $location: ng.ILocationService, PortfolioService, notificationFactory: Common.INotificationFactory, $modal: Common.IModal, $modalInstance: Common.IModalInstance) {
        var ctrl = new Sustainalytics.Portfolio.PortfolioCheckController($rootScope, $scope, $q, $location, PortfolioService, notificationFactory, $modal, $modalInstance);
        return ctrl;
    });
} 
 